import { defineStore } from 'pinia'
import TagModel from '../class/TagModel'
import TreeModel from '../class/TreeModel'
const useStore = defineStore('main', {
    state: () => {
        return {
            isCollapse: false,
            tags: [] as Array<TagModel>,
            token: "",
            UserMenus: [] as Array<TreeModel>,
            RefreshTokenNum: 0
        }
    },
    //状态管理 持久化
    persist: {
        enabled: true, //开启
        strategies: [{
            //指定key，这个名称会在浏览器本地存储中生成对应的name
            key: "site",
            storage: localStorage, //自定义存储方式，默认sessionStorage
            // paths:["UserMenus"]
        }]
    },
    actions:{
        reset(){
            this.token = ""
            this.isCollapse = false
            this.tags = []
            this.UserMenus = []
            this.RefreshTokenNum = 0
        }
    }
})

export default useStore